﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text.RegularExpressions;

namespace DTO.Models
{
    public enum UserType
    {
        user,
        admin
    }

    public class Common
    {
        public const string SessionCookiesUserType = "UserType";
        public static int pagesize = 5;
        public static DateTime datemax = new DateTime(2100, 12, 31);
        public static DateTime datemin = new DateTime(2000, 1, 1);

        public static DateTime ChangeDateVNToUS(string date)
        {
            int day = Convert.ToInt32(date.Split('/')[0]);
            int month = Convert.ToInt32(date.Split('/')[1]);
            int year = Convert.ToInt32(date.Split('/')[2]);
            return new DateTime(year, month, day);
        }

        public static string RemoveUnicode(string accented)
        {
            accented = accented == null ? "" : accented;
            accented = accented.Trim();
            accented = accented.Replace('/', ' ');
            accented = accented.Replace('\\', ' ');
            Regex regex = new Regex(@"\p{IsCombiningDiacriticalMarks}+");
            string strFormD = accented.Normalize(System.Text.NormalizationForm.FormD);
            string rs = regex.Replace(strFormD, String.Empty).Replace('\u0111', 'd').Replace('\u0110', 'D');
            return rs.Replace(' ', '-');
        }

    }
}